﻿using System;
using System.Windows.Data;

namespace Autorent.Desktop.Main.Converters
{
    /// <summary>
    /// Convert "m" or "f" to gender "Male" or "Female", and back
    /// </summary>
    [ValueConversion(typeof(string), typeof(string))]
    public class GenderToByteConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null) { value = ((string)value == "m") ? "Male" : "Female"; }
            else { value = "Male"; }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null) { value = ((string)value == "Male") ? "m" : "f"; }
            else { value = "m"; }

            return value;
        }
    }
}
